[5.1] Backport BAG failover fix. Ignore server provided failover partner.#3704
[5.1] Backport BAG failover fix. Ignore server provided failover partner.#3704mdaigle merged 10 commits intorelease/5.1from
Conversation
* Add IgnoreServerProvidedFailoverPartner app context switch. * Add behavior skip to netfx. * Consolidate to single property for failover partner value. * Rework checks to preserve server provided value, but ignore it. * Fix import. * Skip server failover partner override in �LoginNoFailover method. Add simulated server test coverage.
There was a problem hiding this comment.
Pull Request Overview
This PR backports a fix from PR #3625 to the 5.1 branch that addresses Basic Availability Group (BAG) failover issues by adding an option to ignore server-provided failover partners. The implementation adds a new AppContext switch that allows applications to explicitly control failover behavior instead of relying on server-provided values.
Key Changes:
- Introduced
IgnoreServerProvidedFailoverPartnerAppContext switch to control failover partner behavior - Refactored
ServerProvidedFailOverPartnerproperty from a field-backed read-only property to an auto-property with consistent naming - Updated failover logic to conditionally use server-provided values based on the new switch
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| LocalAppContextSwitches.cs | Adds the new IgnoreServerProvidedFailoverPartner switch with documentation |
| SqlInternalConnectionTds.cs (netfx) | Refactors failover partner property and implements conditional logic based on the new switch |
| SqlInternalConnectionTds.cs (netcore) | Same changes as netfx version for .NET Core platform |
| SqlCommand.cs (netfx) | Updates property reference to use corrected naming |
| SqlCommand.cs (netcore) | Updates property reference to use corrected naming |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/5.1 #3704 +/- ##
===============================================
+ Coverage 71.82% 71.99% +0.16%
===============================================
Files 293 293
Lines 61659 61610 -49
===============================================
+ Hits 44289 44354 +65
+ Misses 17370 17256 -114
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
paulmedynski
left a comment
There was a problem hiding this comment.
I think these changes are risky without the accompanying tests.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Show resolved
Hide resolved
benrr101
left a comment
There was a problem hiding this comment.
Paul's comments are good - Since the overall approval is gated on his, I'll approve.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs
Show resolved
Hide resolved
|
@benrr101 @paulmedynski comments addressed and I backported the test included in the original PR. |
paulmedynski
left a comment
There was a problem hiding this comment.
Asking for one clarification.
Description
Backports #3625